package main

import (
	"csswebdown/lib"
	"fmt"
	"runtime"
)

func main() {
	fmt.Println("......starting......")
	Start()
	fmt.Println(".........end........")
}
func Start() {
	for i := 5; i < 107; i++ {
		url := "http://sc.chinaz.com/jiaoben/index_" + fmt.Sprint(i) + ".html"
		build(url)
	}
}
func build(url string) {
	pages := lib.GetURl(url)
	Process(pages, 10)
}
func init() {
	runtime.GOMAXPROCS(runtime.NumCPU())
}
func Process(pages []*lib.Pageitem, nubpro int) {
	ch := make(chan *lib.Pageitem, runtime.NumCPU())
	rs := lib.Bf(ch, nubpro)
	for i := 0; i < len(pages); i++ {
		ch <- pages[i]
	}
	close(ch)

	for i := 0; i < nubpro; i++ {
		<-rs
	}
}
